List of Units and Procedures

 Unit EGLE95

 interface

 uses
  SysUtils, Windows, WinTypes, WinProcs, Messages, Classes, Graphics,
  Controls, Forms, Dialogs, Tabs, ExtCtrls,
  StdCtrls, Menus, Symbols, GLETools;

 type
  TEditForm = class(TForm)
    SourceMenu: TMainMenu;
    F1: TMenuItem;
    Edit1: TMenuItem;
    Settings: TMenuItem;
    Blocks: TMenuItem;
    About1: TMenuItem;
    Help1: TMenuItem;
    New1: TMenuItem;
    Open1: TMenuItem;
    Save1: TMenuItem;
    Saveas1: TMenuItem;
    Close1: TMenuItem;
    Print1: TMenuItem;
    Exit1: TMenuItem;
    Cut1: TMenuItem;
    Copy1: TMenuItem;
    Paste1: TMenuItem;
    SetFont: TMenuItem;
    FontLineWidth: TMenuItem;
    SourceControls: TPanel;
    Label1: TLabel;
    Edit2: TEdit;
    NewBtn: TButton;
    DrawBtn: TButton;
    HideBtn: TButton;
    ShowBtn: TButton;
    EditMemo: TMemo;
    Button1: TButton;
    SetColor: TMenuItem;
    SetLine: TMenuItem;
    SetFill: TMenuItem;
    BeginBox: TMenuItem;
    BeginClip: TMenuItem;
    BeginOrigin: TMenuItem;
    BeginPath: TMenuItem;
    BeginRotate: TMenuItem;
    BeginScale: TMenuItem;
    BeginTable: TMenuItem;
    BeginText: TMenuItem;
    BeginTranslate: TMenuItem;
    Delete1: TMenuItem;
    SaveDialog1: TSaveDialog;
    OpenDialog1: TOpenDialog;
    PrintDialog1: TPrintDialog;
    FontDialog1: TFontDialog;
    procedure NewBtnClick(Sender: TObject);
    procedure Cut1Click(Sender: TObject);
    procedure Copy1Click(Sender: TObject);
    procedure Paste1Click(Sender: TObject);
    procedure DrawBtnClick(Sender: TObject);
    procedure HideBtnClick(Sender: TObject);
    procedure ShowBtnClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Save1Click(Sender: TObject);
    procedure Saveas1Click(Sender: TObject);
    procedure Open1Click(Sender: TObject);
    procedure Delete1Click(Sender: TObject);
    procedure SetFontClick(Sender: TObject);
    procedure New1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

 var
   EditForm: TEditForm;
   SubStringNum,CurrentLineColor:Integer;
   FileName1:String;


 implementation

  uses Graphs,GLEDisp;

    procedure TEditForm.NewBtnClick(Sender: TObject);
    
    procedure TEditForm.Cut1Click(Sender: TObject);

    procedure TEditForm.Copy1Click(Sender: TObject);

    procedure TEditForm.Paste1Click(Sender: TObject);

    procedure AddLine(Istart,Iend:integer);
    { Adds an analysis of current line to the text file}

    procedure SetBox(item:integer);

    procedure SetClip(item:integer);

    procedure SetClip(item:integer);

    procedure SetUpKey(item:integer);

    procedure SetPath(item:integer);

    procedure SetTable(item:integer);

    procedure SetText(item:integer);

    procedure BeginBlock(Item:Integer);
    {Carries out operations at the start of a block}

    procedure EndBlock(Item:integer);
    {Carries out operations at the end of a block}

    procedure MakeSetting(Item:Integer);
    {Carries out operations following a Setting Command}

    procedure SetDataPlot(AtString:integer;PlotNum:integer);
    { Enters data into plotdata[plotnum].
      PlotNum is the number of the plot column. }

    procedure SetUpAxis(Var AxisName:taxis;Item:integer);
    {Sets up a graph axis. AxisType is code for Axis. Item is current
     position in string array}

    procedure DoLine(var Eposn,Etype:integer;NumOfSubStrings:integer);

    procedure TEditForm.DrawBtnClick(Sender: TObject);
    {Compiles listing and displays the resulting graphics}

    procedure TEditForm.HideBtnClick(Sender: TObject);

    procedure TEditForm.ShowBtnClick(Sender: TObject);

    procedure TEditForm.Button1Click(Sender: TObject);
    {Resets defaults prior to drawing}

    procedure TEditForm.FormCreate(Sender: TObject);
    {Initial program settings}

    procedure TEditForm.Save1Click(Sender: TObject);
    {saves current GLE file}

    procedure TEditForm.Saveas1Click(Sender: TObject);
    {saves current GLE file under another name.}

    procedure TEditForm.Open1Click(Sender: TObject);
    {Opens file}

    procedure TEditForm.Delete1Click(Sender: TObject);

    procedure TEditForm.SetFontClick(Sender: TObject);

    procedure TEditForm.New1Click(Sender: TObject);


  Unit Graphs.
{ Covers operations involved in drawing a graph}

 interface
 uses
  Windows, SysUtils, WinTypes, WinProcs,
  Messages, Classes, Graphics, Controls, Forms, Dialogs,
  Tabs, ExtCtrls, StdCtrls, Menus, GLEDisp, GLETools;

 type
   AxisTitle=record
     name:string;
     color:integer;
     hei,dist:double;
   end;

   DataItem=record
     Status:char;
     Value:double;
   end;
   tAxis=record        {Data for linear axes}
     xstart,ystart,xend,yend,  {Coordinates of end points}
     AxisLength,AxisHeight,    {AxisHeight covers angle of axis relative to
                                horizontal or vertical}
     ScaleHi,ScaleLo,                            {Scale limits}
     TickStart,SubTickStart,MidTickStart,        {First tick positions}
     dTicks,dSubTicks,dMidTicks,                 {Tick spacings}
     TickLength,SubTickLength,MidTickLength,
     TickLineWidth,SubTickLineWidth,MidTickLineWidth,
     TickAngle,
     GridStart,SubGridStart,MidGridStart,        {Grid Starting Points}
     dGrid,dSubGrid,dMidGrid,GridLength,         {Grid spacings}
     GridLineWidth,SubGridLineWidth,MidGridLineWidth,
     GridAngle,TitleAngle,
     NameDist,NameShift,NameAngle,
     AxisLineWidth,
     MidLabelShift,MidLabelDist,                 {Label positions}
     LabelShift,LabelDist,LabelAngle,
     TitleHei,MidLabelHei,LabelHei,NameHei,              {Text heights in cm}
     TitleShift,TitleDist:double;                {Title position}

     nTicks,nSubTicks,nMidTicks,                 {Number of ticks}
     nGrids,nSubGrids,nMidGrids,                 {Number of Grid lines}
     AxisType,                                   {Axis Type}
     TickColor,SubTickColor,MidTickColor,        {Tick colors}
     GridColor,SubGridcolor,MidGridColor,        {Grid colors}
     AxisColor,NameColor,
     NumOfNames,NumOfPlaces,                     {Size of arrays}
     TitleColor,MidLabelColor,LabelColor:integer; {Title colors}
     TickStyle,SubTickStyle,MidTickStyle,        {Tick styles}
     GridStyle,SubGridStyle,MidGridStyle,        {Grid and tick line styles}
     AxisLineStyle:TPenStyle;
     Title,TitleFontName,LabelFontName,MidLabelFontName,NameFontName:string;
     AxisLabels,AxisName:array[0 ..50] of string;
     ShowName,ShowPlace,ShowMidPlace:array[0 .. 50] of boolean;
     AxisOff,SideOn,Negate,                        {Flags}
     NoFirst,NoLast,LabelsOn,MidLabelsOn,
     GridOn,TicksOn,MidTicksOn,SubTicksOn,NamesOn:Boolean;
   end; {tAxis}

   gdata=record
     name:string;
     dcol:array[0 ..99] of Byte;
   end;

   plotset=record
     xaxis,yaxis,zaxis, {defines either x1axis or x2axis etc.}
     xcol,ycol,NumOfPoints,
     pcolor,mlcolor,mfcolor,
     pstyle, mstyle,
     smoothvalue:integer;
     errwidth,errup,errdown,
     herrwidth,herrleft,herrright,
     pwidth,msize,
     gca,gcb,gcc,     {Plot to paper coordinate transform }
     gcd,gce,gcf:double;
     markeron,lineon,erron,
     xIsLog,yIsLog,
     smooth:boolean;
   end;

   pdata= array[0 .. 99] of plotset;
   Datacol=array[ 0 .. 250] of DataItem;
   DataSet=array [0 .. 99] of DataCol;

 var gxsize,gysize,             {Graph Dimensions}
     gstartx,gstarty,           {Start point for graph box}
     GTitleDist,GTitleOffset,           {Grapph Title Position}
     gxorigin,gyorigin,         {Graph Origin}
     hscale,vscale,             {Axis scale factors}
     GTitleHei:double;          {Title Height}
     GTitleColor,
     DataColNum,NumOfDataCols,  {Data Column settings}
     CurrentDstart,CurrentDEnd,
     LastDStart,LastDEnd,
     DataRowNum,NumOfDataRows:integer;
     x1axis,x2axis,y1axis,y2axis,z1axis,z2axis,AxisName:tAxis;
     UseX1Axis,UseX2Axis,UseY1Axis,UseY2Axis,
     NoBox,FullSize:Boolean;
     GTitle,GTitleFontName,
     DataSetName:string;             {Graph Title}
     Linc:array[0..19] of double;
     CurrentPenStyle:TPenStyle;
     CurrentBrushStyle:TBrushStyle;
     DataCol1:dataCol;
     Data:DataSet;
     PlotIsOn:array[0 .. 99] of Boolean;
     PlotData:pdata;       {The array of plotting data sets }
     CurrentPlot:plotset;  {The current set of plot data}

 procedure AutoScale(DataHi,DataLo:double;VAR ScaleHi,
                   ScaleLo:double;VAR NumOfSeg,ScaleType:integer);
 {Takes as input upper and lower data limits DataHi,DataLo and scale type
  ScaleType ( 1 for linear, 2 for log, 3 for probability scale ).
  Resets ScaleType if necessary and returns suitable upper and lower
  scale limits ScaleHi,ScaleLo. NumOfSeg is no. of segments in a linear scale
  or no. of decades*100 in a log. scale   }

  procedure DrawAxis(var Axis:tAxis);
  { Draws a linear or logarithmic axis specified by:
    ScaleLo - lower value of axis range
    ScaleHi - upper limit of axis range
    xstart,ystart - co-ordinates of start of axis
    xend,yend     - co-ordinates of end of axis,
    dStart - first point for ticks,
    dTicks - distance between ticks
    dSubStart,dSubticks - same for subticks
    dMidStart,dMidTicks - same for middle ticks
    TickAngle - Angle of ticks relative to axis
    Mark1Leng,Mark2Leng,Mark3Leng - scale marker lengths
    LogStyle - Submark style for a log axis
    AxisType - axis type: 1 = linear, 2 = logarithmic        }

 procedure SetAxisDefaults;
 {Resets all axis parameters to default values}

 procedure PlotToPaper(xd,yd:double;CurrentPlot:plotset; var xp,yp:double);
 {Converts plotter data co-ordinates xd,yd to paper co-ordinates
  xp,yp using the conversion parameters gca,gcb,gcc,gcd,gce,gcf,
  xIsLog,yIslog from the current data set. }

 procedure SetPlotDefaults(PlotNumber:integer);
 {Resets  a plot data record to default settings }

 procedure SetUpGraph;
 {At the start of a graph block this procedure
  performs initialisation operations for the graph}

 procedure ConstructGraph;
 {At end f a graphics block this procedure uses the
  input to the block to construct the graph and plot
  the data.}

 procedure Inputdata(var Colnum:integer;DataSetName:string);
 {Organises input of data to DataSet Data}

 {function FileExists(FileName: string): Boolean;
 { Boolean function that returns True if the file exists; otherwise,
   it returns False. Closes the file if it exists. }

 procedure CheckData;
 {Temporary test output from data array. }

 implementation

 var ig,jg,kg:integer;
     xg,yg,x1g,y1g:double;


    function Entier(x:double):integer;
    { Returns the largest integer less than X }

    procedure Mant(x:double;VAR Mantissa:DOUBLE;VAR Exponent:INTEGER);
    { Extracts the mantissa and exponent of a real number X  
      Version 1. D. Ingram.  3/8/87                         }

    procedure AutoScale(DataHi,DataLo:double;VAR ScaleHi,
                   ScaleLo:double;VAR NumOfSeg,ScaleType:integer);

    { Takes as input upper and lower data limits DataHi,DataLo and scale type
      ScaleType ( 1 for linear, 2 for log, 3 for probability scale ).
      Resets ScaleType if necessary and returns suitable upper and lower
      scale limits ScaleHi,ScaleLo. NumOfSeg is no. of segments in a linear scale
      or no. of decades*100 in a log. scale   }

    procedure DrawAxis(var Axis:tAxis);
    { Draws a linear or logarithmic axis specified by:
      ScaleLo - lower value of axis range
      ScaleHi - upper limit of axis range
      xstart,ystart - co-ordinates of start of axis
      xend,yend     - co-ordinates of end of axis,
      dStart - first point for ticks,
      dTicks - distance between ticks
      dSubStart,dSubticks - same for subticks
      dMidStart,dMidTicks - same for middle ticks
      TickAngle - Angle of Ticks relative to axis
      Mark1Leng,Mark2Leng,Mark3Leng - scale marker lengths
      LogStyle - Submark style for a log axis
      AxisType - axis type: 1 = linear, 2 = logarithmic        }


      Procedure SetAxisDefaults;
      {Resets all axis parameters to default values}

      procedure PlotToPaper(xd,yd:double;CurrentPlot:plotset; var xp,yp:double);
      {Converts plotter data co-ordinates xd,yd to paper co-ordinates
       xp,yp using the conversion parameters gca,gcb,gcc,gcd,gce,gcf,
       xIsLog,yIslog from the current data set. }

      procedure SetPlotDefaults(PlotNumber:integer);
      {Resets  a plot data record to default settings }

      procedure SetUpGraph;

      Procedure ConstructGraph;
      {Sets up a graph using parameters as set in this module
       This is currently a dummy version for development}


      procedure InputData(var Colnum:integer;DataSetName:String);
      {Organises input of plot data from a file.
       Colnum is the current last data column.}

      procedure CheckData;
      { A test of setup of the Data array}

      initialization

  Unit  GLEDisp

 interface

 uses
  Windows, Messages, SysUtils,WinTypes,WinProcs, Graphics, Controls, Forms,
  Dialogs, Tabs, StdCtrls, ExtCtrls, EGLE95, Classes,GLETools, Menus, Buttons;

 type
  TDisplayForm = class(TForm)
    DisplayPanel: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Label4: TLabel;
    LineButton: TButton;
    BezierButton: TButton;
    BoxButton: TButton;
    CircleButton: TButton;
    EllipseButton: TButton;
    NArcButton: TButton;
    MarkButton: TButton;
    TextButton: TButton;
    TextEdit: TEdit;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    CopyButton: TButton;
    PrintButton: TButton;
    PasteButton: TButton;
    ClearButton: TButton;
    Image1: TImage;
    ModeButton: TButton;
    Button1: TButton;
    SquareButton: TButton;
    MainMenu1: TMainMenu;
    File1: TMenuItem;
    Line1: TMenuItem;
    Brush1: TMenuItem;
    Colour1: TMenuItem;
    Load1: TMenuItem;
    Save1: TMenuItem;
    Exit1: TMenuItem;
    Style1: TMenuItem;
    Colour2: TMenuItem;
    Width1: TMenuItem;
    Style2: TMenuItem;
    Pattern1: TMenuItem;
    Colour3: TMenuItem;
    Font1: TMenuItem;
    Size1: TMenuItem;
    Colour4: TMenuItem;
    OffButton: TBitBtn;
    procedure FormCreate(Sender: TObject);
    procedure LineButtonClick(Sender: TObject);
    procedure BoxButtonClick(Sender: TObject);
    procedure BezierButtonClick(Sender: TObject);
    procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure TextButtonClick(Sender: TObject);
    procedure EllipseButtonClick(Sender: TObject);
    procedure MarkButtonClick(Sender: TObject);
    procedure ArcButtonClick(Sender: TObject);
    procedure CopyButtonClick(Sender: TObject);
    procedure PrintButtonClick(Sender: TObject);
    procedure PasteButtonClick(Sender: TObject);
    procedure ClearButtonClick(Sender: TObject);
    procedure RadioButton1Click(Sender: TObject);
    procedure RadioButton2Click(Sender: TObject);
    procedure CircleButtonClick(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Image1DblClick(Sender: TObject);
    procedure NArcButtonClick(Sender: TObject);
    procedure SquareButtonClick(Sender: TObject);
    procedure OffButtonClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
   private
    { Private declarations }
   public
  end;
  CTransform = Record
    XOrigin,
    YOrigin,
    TranC, TranE, TranD, TranF,
    XScale, YScale,
    Rotation:double;
  end;
 {  MStyle = array[0 .. NumOfMarkers] of String;  }
   TDrawingTool = (dtNone, dtLine, dtArc, dtBox, dtSquare, dtBezier,
                  dtCircle, dtEllipse, dtMarker, dtText,dtContinue);
  TMarkerType  = (mtCircle, mtTriangle, mtSquare, mtDiamond,
                  mtDot, mtCross, mtStar, mtSnake, mtDag,
                  mtDdag, mtAsterisk, mtOplus, mtOminus,
                  mtOtimes);

 var
  DisplayForm: TDisplayForm;
  BitMap,BitMap1:tbitmap;

  CurrentItem,FinalItem,ip,SpotSize,
  GLEHeight,GLEWidth,DisplayHeight,
  MarkerType,MarkerSize:integer;
  PixelsPerCm,
  XOffset,YOffset,TextAngle,
  TranA,TranB,TranC,TranD,TranE,TranF,            {Co-ordinate transformations}
  TranAi,TranBi,TranCi,TranDi,TranEi,TranFi:double; {Inverse Transformations}
  MouseMode,KeyMode,SetCurve,NewStyle,NewDrawObject,Drawing,
  NewDrawing,StartDraw,Clockwise: Boolean;
  DrawStart,LastStart, DrawEnd,LastEnd,CStart,CEnd,
  ControlPoint1,ControlPoint2,TextAt :TPoint;
  DrawingTool: TDrawingTool;
  DrawingMode, LastDmode, {Controls for complex drawing operations}
  DrawingStyle,
  CTransformNum,                {Level in Coordinate Transform Stack }
  BeginNum,BeginValue:Integer;  {Level & Value in Begin stack }
  ap1:array[0 ..100] of tpoint;
  CurrentTransform,CurrentInvTransform:CTransform;
  Ctrans:array [0 ..  25] of CTransform;
  {Stack used to check begin/end matchings}
  BeginStack: array[ 0 .. 50] of integer;
  TextOut:String;
  CurrentFont,DefaultFont:TFont;
  MarkerStyle:array[ 0 ..30] of string;
  CurrentPoint:RealPoint;

  function SetPenStyle(Tpen:integer):TPenStyle;
  {Sets a pen style According to The current style code}

  function SetBrushStyle(TBrush:integer):TBrushStyle;
  {Sets a brush style According to the current style code}


  function  InverseTransform(CurrentTransform:CTransform):CTransform;
  {Forms the inverse of the current Transform}

  function TransformPoint(CurrentTransForm:CTransform;
                          Inpoint:RealPoint):Realpoint;
 { Converts current co-ordinate values}

  function ScreenPoint(Input:RealPoint):TPoint;
  {Derives screen coordinates for a plot point}

  function ToRealPoint(Input:Tpoint):RealPoint;
  {Derives co-ordiates in cm corresponding to a screen point
   Note, these are absolute coordinates}

  procedure DrawBezier(scale:double;x1,y1,xc1,yc1,xc2,yc2,x2,y2,
          dmode:integer);
    { Constructs a 2-Dimensional Besier spline from x1,y1 to
      x2,y2 using control points xc1,yc1 and xc2,yc2.
      Plots this on the screen using scale factor `scale' and
      mode control `dmode'.
      Set up modes 1 to 3 use narrow black lines
      dmode = 0 does nothing,
      dmode = 1 plots the straight line from start to end,
      dmode = 2 plots control points.
      dmode = 3 plots 1st control vector and curve
      dmode = 4 plots 2nd control vector and curve
      dmode = 5 plots curve only in black.
      dmode = 6 plots curve in original style and color.  }

    procedure DrawArc(x1,y1,xc,yc,xa,ya,dmode:integer;var x2,y2:longint;
                       var Radius,StartAngle,EndAngle:double;Clock:boolean);
   { Constructs an arc from x1,y1 to x2,y2 using control points
     xc,yc and xa,ya. xc,yc is the centre of the arc, the arc ends at
     the intersection with the line from xc,yc to xa,ya.
     The arc is drawn clockwise if Clock is TRUE.
     Plots this on the screen using mode control `dmode' as follows:
     Set up modes 1 to 3 use narrow black lines
     dmode = 0 does nothing,
     dmode = 1 plots the initial straight line from x1,y1 to xc,yc,
     dmode = 2 plots control points at x1,y1,xc,yc and xa,ya.
     dmode = 3 plots arc and 1st control vector in black.
     dmode = 4 plots arc and 2nd control vector in black.
     dmode = 6 plots arc in original style and color.  }

 procedure DrawMarker(mtype,x,y:integer;mscale:double);
 { Draws a marker of type mtype and size mscale at x,y
   Colours and fill style are set in DrawMain before calling this
   procedure }


 function IntString(I: Longint): string;
 { Converts any integer type to a string }

 function RealString(R: real): string;
 { Convert any real type to a string }

 procedure DisplayObject(step:integer);
 { This draws an object in final form, then sets it up in
   list of graph objects, and increments item number
   For Bezier and Arc functions Flag SetCurve is reset.  }

 { ************ Procedures for GLE operations ************** }

  procedure Aline(x,y:double);
  {Draws a line to x,y and makes this the current point}

  procedure Amove(x,y:double);
  {Moves Current point to x,y}

  procedure ArcAt(xradius,yradius,startangle,endangle:double);
  {draws a simple arc centred at current point}

  procedure Bezier(xc1,yc1,xc2,yc2,xend,yend:double);
  {Draws a Bezier curve from the current point to xend,yend
   and moves current point to xend,yend }

  procedure BSpline(StepSize:double;Fit,NumOfCpts:integer;
                    Cpoint:array of realpoint);
  {Draws a B-spline curve starting from xstart,ystart and endind at
   xend,yend. An array Cpoint of control points is used. This starts
   at point 1 and holds NumOfCpoints entries. The curve is drawn using
   the current pen color, style etc. and using the current coordinate
   transform settings. StepSize is the size of the steps in each segment
   which defines the smoothness of the curve. This is set to a default
   of 0.05 but may be reset in the GLE listing during a run }

  procedure box(x,y:double);
  {Draws a box from current point to x,y}

  procedure EllipseAt(xradius,yradius:double);
  { Draws an ellipse centred at current point }

  procedure Circle(radius:double);
  {Draws a circle centred onthe current point}

  procedure Marker(mktype:string;size:double);
  {Draws a marker at the curent point}

  procedure RBezier(xc1,yc1,xc2,yc2,xend,yend:double);
 {Draws a Bezier curve from the current point to xend,yend
  and moves current point to xend,yend where all parameters
  are relative to the current point  }


  procedure Rline(x,y:double);
  {Draws a line to x,y relative to present point}

  procedure Rmove(x,y:double);
  {Moves Current point to x,y relative to present point}

  procedure square(xx:double);
  {Draws a box centred on the current point }

  procedure Text(TextString:string;Angle:Double);
  {Displays a simple Text String}

 implementation

 uses Graphs;

 var  TextOn:Boolean;
      FontRecord:TlogFont;

 {$R *.DFM}

  function SetPenStyle(Tpen:integer):TPenStyle;
  {Sets a pen style According to The current style code}

  function SetBrushStyle(TBrush:integer):TBrushStyle;
  {Sets a brush style According to the current style code}


  function  InverseTransform(CurrentTransform:CTransform):CTransform;
  {Forms the inverse of the current Transform}

  function TransformPoint(CurrentTransForm:CTransform;
                          Inpoint:RealPoint):Realpoint;
 { Converts current co-ordinate values}

  function ScreenPoint(Input:RealPoint):TPoint;
  {Derives screen coordinates for a plot point}

  function ToRealPoint(Input:Tpoint):RealPoint;
  {Derives co-ordiates in cm corresponding to a screen point
   Note, these are absolute coordinates}

    procedure FormCreate(Sender: TObject);

    procedure LineButtonClick(Sender: TObject);

    procedure BoxButtonClick(Sender: TObject);


    procedure BasicArc(var Arcpoint:array of RealPoint;XCentre,YCentre,
                   XRadius,YRadius,StartAngle,EndAngle:double);
    {Sets up an array of points defining an elliptical arc,
     centre at Xcentre,YCentre, radii Xradius,YRadius,
     running from StartAngle to EndAngle. All co-ordinates in cms
     and angles in degrees. Note that because basic pixel y coordinates start
     at top of screen this draws a clockwise arc. After first applying
     coordinate transforms arc will conform to conventional practice.}

     procedure BezierButtonClick(Sender: TObject);


     procedure DrawBezier(scale:double;x1,y1,xc1,yc1,xc2,yc2,x2,y2,
          dmode:integer);
     { Constructs a 2-Dimensional Besier spline from x1,y1 to
      x2,y2 using control points xc1,yc1 and xc2,yc2.
      Plots this on the screen using scale factor `scale' and
      mode control `dmode'.
      Set up modes 1 to 3 use narrow black lines
      dmode = 0 does nothing,
      dmode = 1 plots the straight line from start to end,
      dmode = 2 plots control points.
      dmode = 3 plots 1st control vector and curve
      dmode = 4 plots 2nd control vector and curve
      dmode = 5 plots curve only in black.
      dmode = 6 plots curve in original style and color.  }

    procedure DrawArc(x1,y1,xc,yc,xa,ya,dmode:integer;var x2,y2:longint;
                       var Radius,StartAngle,EndAngle:double;Clock:boolean);
   { Constructs an arc from x1,y1 to x2,y2 using control points
     xc,yc and xa,ya. xc,yc is the centre of the arc, the arc ends at
     the intersection with the line from xc,yc to xa,ya.
     The arc is drawn clockwise if Clock is TRUE.
     Plots this on the screen using mode control `dmode' as follows:
     Set up modes 1 to 3 use narrow black lines
     dmode = 0 does nothing,
     dmode = 1 plots the initial straight line from x1,y1 to xc,yc,
     dmode = 2 plots control points at x1,y1,xc,yc and xa,ya.
     dmode = 3 plots arc and 1st control vector in black.
     dmode = 4 plots arc and 2nd control vector in black.
     dmode = 6 plots arc in original style and color.  }

    procedure DrawMarker(mtype,x,y:integer;mscale:double);
    { Draws a marker of type mtype and size mscale at x,y
      Colours and fill style are set in DrawMain before calling this
      procedure }

    procedure DrawText(x,y:integer;Scale,Rotate:double;TextItem:String);
    { Draws a text string or a maths symbol }


    function IntString(I: Longint): string;
    { Converts any integer type to a string }

    function RealString(R: real): string;
    { Convert any real type to a string }

    procedure DisplayObject(step:integer);
    { This draws an object in final form, then sets it up in
      list of graph objects, and increments item number
      For Bezier and Arc functions Flag SetCurve is reset.  }


    procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
 
    procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);

    procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);

    procedure TextButtonClick(Sender: TObject);

    procedure EllipseButtonClick(Sender: TObject);

    procedure MarkButtonClick(Sender: TObject);

    procedure ArcButtonClick(Sender: TObject);

    procedure CopyButtonClick(Sender: TObject);

    procedure PrintButtonClick(Sender: TObject);

    procedure PasteButtonClick(Sender: TObject);

    procedure ClearButtonClick(Sender: TObject);

    procedure RadioButton1Click(Sender: TObject);

    procedure RadioButton2Click(Sender: TObject);

    procedure CircleButtonClick(Sender: TObject);

    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);

    procedure Image1DblClick(Sender: TObject);

    procedure NArcButtonClick(Sender: TObject);

    procedure SquareButtonClick(Sender: TObject);

    procedure OffButtonClick(Sender: TObject);

    { ************ Procedures for GLE operations ************** }

  procedure Aline(x,y:double);
  {Draws a line to x,y and makes this the current point}

  procedure Amove(x,y:double);
  {Moves Current point to x,y}

  procedure ArcAt(xradius,yradius,startangle,endangle:double);
  {draws a simple arc centred at current point}

  procedure Bezier(xc1,yc1,xc2,yc2,xend,yend:double);
  {Draws a Bezier curve from the current point to xend,yend
   and moves current point to xend,yend }

  procedure BSpline(StepSize:double;Fit,NumOfCpts:integer;
                    Cpoint:array of realpoint);
  {Draws a B-spline curve starting from xstart,ystart and endind at
   xend,yend. An array Cpoint of control points is used. This starts
   at point 1 and holds NumOfCpoints entries. The curve is drawn using
   the current pen color, style etc. and using the current coordinate
   transform settings. StepSize is the size of the steps in each segment
   which defines the smoothness of the curve. This is set to a default
   of 0.05 but may be reset in the GLE listing during a run }

  procedure EllipseAt(xradius,yradius:double);
  { Draws an ellipse centred at current point }

  procedure box(x,y:double);
  {Draws a box from current point to x,y}

  procedure Circle(radius:double);
  {Draws a circle centred onthe current point}

  procedure Marker(mktype:string;size:double);
  {Draws a marker at the curent point}

  procedure RBezier(xc1,yc1,xc2,yc2,xend,yend:double);
  {Draws a Bezier curve from the current point to xend,yend
   and moves current point to xend,yend where all parameters
   are relative to the current point  }


  procedure Rline(x,y:double);
  {Draws a line to x,y relative to present point}

  procedure Rmove(x,y:double);
  {Moves Current point to x,y relative to present point}

  procedure square(xx:double);
  {Draws a box centred on the current point }

  procedure Text(TextString:string;Angle:Double);
  {Displays a simple Text String}

  *****************  End of GLE procedures ***************

   procedure TDisplayForm.FormActivate(Sender: TObject);



  
 Unit GLETools

 {Utilities for GLE95
 Version 1. D. Ingram 1st April 1998        }

 interface

 uses
   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics,
   Controls,Forms, Dialogs, Tabs, ExtCtrls, Style1, MrkStyle,
   StdCtrls, Menus,Symbols, Spin, Buttons;

 const
    Degree=57.2957795130823208767;
    DegToRad=1.0/Degree;
    Exp1=  2.7182818284590452353;
    Gamma=  0.5772156649015328606;
    LogE=   0.4342944819032518277;
    NumOfMarkers=30;
    NumOfcolors= 44;
    NumOfStrings=50;                  {Number of substrings in a line }
    Pi=     3.1415926535897932384;
    angle:double=1.0;
    SigFigs:integer=5;
    DecFigs:integer=2;
  {colour constants}
    Black      = $00000000;
    White      = $00FFFFFF;
    DarkRed    = $000000B5;
    Red        = $000000FF;
    LightRed   = $00AAAAFF;
    DarkGreen  = $00009000;
    Green      = $0000E000;
    LightGreen = $00BAE0BA;
    DarkBlue   = $00900000;
    Blue       = $00FF0000;
    LightBlue  = $00FFBABA;
    DarkBrown  = $004070A0;
    Brown      = $000090E0;
    LightBrown = $0070C0FF;
    Yellow     = $0000FFFF;
    DarkGrey   = $00707070;
    MidGrey    = $00A0A0A0;
    Grey       = $00C0C0C0;
    Silver     = $00D0D0D0;
    LightGrey  = $00E0E0E0;
    Maroon     = $0060009A;
    Olive      = $005090A0;
    Purple     = $00A000A0;
    Fuschia    = $00D070E9;
    Lime       = $00A8F800;
    Aqua       = $00FFFF90;
    Primrose   = $00B0FFFF;
    Parchment  = $00D0FFFF;
    Peach      = $00CCE0FF;
    OffWhite   = $00F8F8F8;
    Lavender   = $00FFF0F8;
    BlueTint   = $00FFFFF0;
    GreenTint  = $00E6FFE6;
    Pink       = $00EAE5FF;

 type Mrkrs=Array[0 .. NumOfMarkers] of String;
     clrs =Array[0 .. NumOfColors]  of String;
     
     RealPoint = Record
       x:double;
       y:double;
     end;
 const
   Markers:mrkrs=('circle','triangle','square','diamond','fcircle',
                  'ftriangle','fsquare','fdiamond','dot','cross',
                  'club','heart','star','snake','dag',
                  'ddag','asterisk','oplus','ominus','otimes',
                  'odot','trianglez','squarez','diamondz','wcircle',
                  'wtriangle','wsquare','wdiamond','sqdot','dmddot',
                  'plus');
   colors:clrs=('black','white','dkred','red','ltred',
               'dkgreen','green','ltgreen','dkblue','blue',
               'ltblue','dkbrown','brown','ltbrown','yellow',
               'dkgrey','midgrey','grey','silver','ltgrey',
               'maroon','olive','purple','fuschia','lime',
               'aqua','primrose','parchment','peach','Offwhite',
               'lavender','bluetint','greentint','pink','clear',
               'colr0','colr1','colr2','colr3','colr4',
               'colr5','colr6','colr7','colr8','clr9');

 var
  out1,out2,out3:string;
  SetAxis,SetGraph,SetGraphic,SetKey,{Used in line parsing}
  SetPlot,SetPlotStyle,{Set plot flags data input, SetPlotStyle flags plot style}
  AxisSet,KeySet,Diagnostics,Disaster,Inaccurate:Boolean;
  {Used in line parsing}
  StringIndex,LastIndex:integer;
  StringType,LastType:Array[0 .. NumOfStrings] of integer;
  StringText,LastText:Array[0 .. NumOfStrings] of string;
  StringValue,LastValue:Array[0 .. NumOfStrings] of double;
  Getcolor: array[0 .. 50] of integer;
  SetData:Boolean;

 { result:double;    }

{ Procedure GetNumber(NStart:Integer;Var NEnd, Ecode,Errcode:Integer;S:string;
                    EndChars:Symbols;var V:double);
 { Takes a string which has a digit or '-' sign at location Nstart and
   extracts a number from it. Returns the next location following the
   number in the string. The number is terminated by as right bracket
   or arithmetic operator. If O.K. Ecode = 0.0
   If an error returns Ecode as non-zero:
      Ecode = 10 if start character was not a digit.
      Ecode = 11 if a number was not identified.
      Ecode >= 12 if evaluation of the number failed.
                 Value then gives error location }


   Function Atan2(x,y:double):double;
   {Returns arctangent for full range 0 to 2Pi}

   Function Sign(x:double):integer;
   {Sign of a real number}

   Function Isign(x:integer):integer;
   {Sign of an integer number}

   Function RPoint(x,y:double):RealPoint;
   {Sets value of a real point to x,y}

   Procedure MatMult (a,b,c,d:double;var Ta,Tb,Tc,Td:double);
   {Premultiplies 2x2 matrix Ta,tb,tc<td by matrix a,b,c d
    and returns result as in place of original matrix}

   Procedure SetVariableValue(Vs:String; var vl:double);
   {Sets the variable Vs to Value vl
    This version modified for use in GLE95.}

   Procedure ResetPars(Rst:integer);
  {Resets parameters
     Rst = 2 Resets Angle and Output number Format
     Rst = 1 Resets Other parameters
     Rst = 3 Resets everything.}

   procedure RemoveQuotes(Var ss:string);
   {Removes Quotes from a simpleString}


   Procedure Analyse(s1:string;var StringNum:integer);
  {Analyses a string into its constituent components and attempts to
   express each component as a command, variable, function, etc.}


   Function GetLine(Var LineNum:Integer):String;
  { This starts at line number LineNum and attempts to construct
   a compound line by adding continuation lines and skipping
   comment lines. If successful the result is returned as the
   function. Non catastrophic failures allow optional continuation.
   Catastrophic failures also set the Global Flag 'Disaster'.
   Various error messages may be returned.}


   Function GetResult(Var ResetIt,Enum:Integer;s1:String;
               var out1a,out1b,out1c,out1d,out1e:String):Double;

  implementation
   uses EGLE95;   { Watch this!}

  const
    DrawLine=
    '!-----------------------------------------------------------------------';
    MaxLineCount  =  5;
    NumOfAxisPars = 54;
    NumOfCmds     = 20;
    NumOfConst    =  6;
 {   NumOfDataOps  =  4;    }
    NumOfFns      = 60;
    NumOfGraphics = 54;
    NumOfGraphs   = 17;
    NumOfGPars    = 22;
    NumOfPlotpars = 33;
    NumOfKeys     = 10;
    NumOfBgns     = 22;
    NumOfBoxes    =  3;
    NumOfJusts    = 11;
    NumOfLines    =  3;
 {   NumOfMisc    =   3;   }
    NumOfSetngs   = 18;
    Quit          =  3;
    Radian        =  1.0;
  type
    cmds     = Array[0 .. NumOfCmds]     of String;
    constnts = Array[0 .. NumOfConst]    of String;
{    dtops    = Array[0 .. NumOfDataOps]  of String;    }
    fns      = Array[0 .. NumOfFns]      of String;
    grphcs   = Array[0 .. NumofGraphics] of String;
    grphs    = Array[0 .. NumOfGraphs]   of String;
    grphprs  = Array[0 .. NumOfGPars]    of String;
    kys      = Array[0 .. NumOfKeys]     of String;
    bgn      = Array[0 .. NumOfBgns]     of String;
    bxs      = Array[0 .. NumOfBoxes]    of String;
    jst      = Array[0 .. NumOfJusts]    of String;
    lns      = Array[0 .. NumOfLines]    of String;
{    msc      = Array[0 .. NumOfMisc]     of String;   }
    pltpars  = Array[0 .. NumOfPlotpars] of String;
    stngs    = Array[0 .. NumOfSetngs]   of String;
    Symbols  = Set of Char;
    Stops    = Set of char;
    xpars    = array[0 .. NumOfAxisPars] of String;
  const
   Graphics:grphcs=('aline','amove','arc','arcto','begin',
               'bezier','bigfile','box','circle','closepath',
               'curve','define','dfont','ellipse','else',
               'end','endif','fclose','fill','fopen',
               'for','goto','grestore','gsave','icon',
               'if','include','input','join','let',
               'marker','move','narc','newpath','next',
               'piechart','postscript','print','rbezier','return',
               'region','repeat','reverse','rline','rmove',
               'save','set','size','square','sub',
               'text','until','use','while','write');

    Graphs:grphs=('bar','data','end','fill','fullsize',
               'hscale','setkey','let','nobox','size',
               'title','vscale','xaxis','x2axis','yaxis',
               'y2axis','zaxis','z2axis');
    {There should be nocommon graph and axis parameters}
    AxisPars:xpars=('color','font','format','hei','length',
               'lwidth','lcolor','lstyle','dticks','dsubticks',
               'dmidticks','dgrid','dsubgrid','dmidgrid','tickstart',
               'subtickstart','midtickstart','gridstart','subgridstart',
                        'midgridstart',
               'nticks','nmidticks','nsubticks','ngrids','nmidgrids',
               'nsubgrids','max','min','dist','side',
               'tick','midtick','subtick','grid','midgrid',
               'subgrid','angle','title','log','linear',
               'negate','nofirst','nolast','on','off',
               'labels','midlabels','names','places','start',
               'end','shift','offset','midplaces','prob');
    {There should be no common graph and plot parameters}
    PlotPars:pltpars=('autoscale','line','marker','err','errwidth',
                      'errup','errdown','from','herr','herrwidth',
                      'herrleft','herrright','key','lstyle','lwidth',
                      'lcolor','mstyle','msize','mlcolor','mfcolor',
                      'nomiss','smooth','smoothm','xmin','xmax',
                      'ymin','ymax','xaxis','yaxis','x2axis',
                      'y2axis','on','off','xxxxx');
    {these parameters may be same as axis and plot parameters   }
    GraphPars:grphprs=('lstyle','lwidth','color','xxxx','xxxx',
                        'xxxx','pos','hei','offset','from',
                        'to','step','font','dist','on',
                        'grid','log','min','max','dpoints',
                        'length','xxxxx','xxxxx');

      DataOps:symbols=['+','-','*','/','^'];

   keys:kys=('offset','position','text','lstyle','marker',
             'msize','mscale','color','hei','fill',
             'nobox');

   Beginnings:bgn=('origin','rotate','scale','translate','graph',
                   'box','clip','key','path','table',
                   'text','fill','add','nobox','name',
                   'stroke','width','xaxis','x2axis','yaxis',
                   'y2axis','zaxis','z2axis');

   Boxes:bxs=('fill','justify','nobox','name');

   JustTo:jst=('left','centre','right','tl','tc','tr',
        'lc','cc','rc','bl','bc','rc');

   Lines:lns=('arrow','start','end','both');

   Settings:stngs=('cap','but','round','square','color',
      'dashlen','fillstyle','fcolor','font','fontlwidth',
      'hei','join','mitre','round','bevel',
      'just','lwidth','lstyle','lcolor');
  {MathPad commands used for evaluating expressions }
   MPComs:cmds=('now','settings','=','diagnostics','clear','degrees'
               ,'radians','fix','float','xxx','xxx',
               'xxx','xxx','xxx','xxx','xxx',
               'xxx','xxx','xxx','xxx','xxx');
  {MP functions}
    MPfns:fns=('now(','abdate(','date(','left$(',
      'right$(','seg$(','num$(','num1$(','chr$(',       { '1' to '9'}
      'abs(','atn(','cos(','exp(','fix(','int(','len(',
      'log(','log10(','not(','pos(','rnd(','sgn(','sin(',
      'sqr(','sqrt(','tan(','val(','acos(','asin(','atn2(',
      'cosh(','sinh(','tanh(','acosh(','asinh(',        {'A' to 'Z'}
      'atanh(','erf(','erfc(','si(','ci(','gamma(',
      'lgamma(','fact(','bjn(','bkn(','bin(','byn(',
      'bico(','frc(','frs(','xxx','xxx','xxx','xxx','xxx',
      'xxx','xxx','xxx','xg(','yg(','xxx');             {'a' to 'z'}
  {MP variables}
    Letters:Symbols=['a','b','c','d','e','f','g','h','i','j','k',
    'l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','$'];
  {Standard terminators}
    Stop1:Symbols=[' ',';'];
  {Extended terminators}
    Stop2:Symbols=[' ',',',';','('];
    Stop3:Symbols=[',',';',')'];
  {Maths operators}
    MathOps:Symbols=['+','-','~','*','/','^'];
    LogOps:Symbols=['>','<','=','|','&'];
    Digits:Symbols=['0','1','2','3','4','5','6','7','8','9'];
    AddOps:Symbols=['+','-'];
    Constants:constnts=('pie','rad','deg','exp','loge','ln10','NtoDB');
    var
      i,j,k,l,m,n,ii,LastCommandNumber,kommand,VariableEnd,
      StartStringAt,EndStringAt,Laststart,Linepos,StringLength,
      code,code1,code2,codea,codeb,codec,Fval,SetVariable,
      ErrorNumber:integer;
      a,b,c,d,e,f,g,h,o,p,q,r,s,t,u,v,w,x,y,z,vb,VarValue:double;
      vv:array[0 .. 275] of double;
      s2,s3,s4,LastVariable:string;
      ValueSet,AssignVariable,CommaFound,ShStrings,lstructure,
      emessage,enumber:Boolean;
      MPad:TextFile;
    {UsedinMaths Fns}
      glntop: longint;
      gla: ARRAY [1..33] OF double;
      glna: ARRAY [1..100] OF double;

{ function GetString(Var SLength:Integer):string;
  Enters a string from the keyboard until the CR character #13 is
  keyed. Pads it out with two spaces and a return character and
  evaluates its length without the final return character
  This procedure is not valid for Win95 - it might be needed for
  Win 3.x,16 bit versions, or other operating systems.

 var
  ch:char;
  s:string;
  begin
   s:='';
   while ch<>#13 do
   begin
    ch:=readkey;
    if ch<>#13 then write(ch);
    if ch=#8 then delete(s,Length(s),1) else
    if ch<>#13 then s:=s+ch;
   end;
   SLength:=Length(s)+2;
   GetString:=s+'  '+#13;
  end; GetString         }

  function atan2(x,y:double):double;
  {Returns arctangent for range 0 to 2Pi}

  function FindNextChar(Position,SLength:integer;SLine:String;
           EndChars:Symbols):integer;
  { Scans Sline staring at position StartAt and returns
    the position of the next non-space character.
    The space characters are defined by the set EndChars }


  function FindNextSpace(Position,SLength:integer;SLine:String;
           EndChars:Symbols):integer;
  { Scans Sline staring at position StartAt and returns
    the position of the next space character.
    The space characters are defined by the set Endchars }

  Function Sign(x:double):integer;
  {Sign of a real number}

  Function Isign(x:integer):integer;
  {Sign of an integer number}

  Function RPoint(x,y:double):RealPoint;
  {Sets value of a real point to x,y}

  Procedure MatMult (a,b,c,d:double;var Ta,Tb,Tc,Td:double);
  {Premultiplies 2x2 matrix Ta,tb,tc<td by matrix a,b,c d
   and returns result as in place of original matrix}

  Function GetVariableName(StartAt:integer;Var EndAt,ReturnCode,
            Ecode,Ecode1:integer;Vs:OpenString;EndChars:symbols):string;
  {Checks one or two locations from Startat for a variable name .
   If found returns the name as a string. Otherwise returns
   Ecode =1 Stop codes are defined by EndChars}

  Function GetVariableValue(Vs:openString;Var Ecode,Ecode1:integer):double;
  {Evaluates the variable defined by Vs}

  Procedure SetVariableValue(Vs:String; var vl:double);
  {Sets the variable Vs to Value vl
   This version has been modified for use in GLE95 by
   removing references to output strings and using a message box
   to report errors. }

  Procedure GetNumber(NStart:Integer;Var NEnd, Ecode,Errcode:Integer;S:string;
                    EndChars:Symbols;var V:double);
  { Takes a string which has a digit or '-' sign at location Nstart and
    extracts a number from it. Returns the next location following the
    number in the string. The number is terminated by as right bracket
    or arithmetic operator. If O.K. Ecode = 0.0
    If an error returns Ecode as non-zero:
      Ecode = 10 if start character was not a digit.
      Ecode = 11 if a number was not identified.
      Ecode >= 12 if evaluation of the number failed.
                 Value then gives error location }


 {Special Maths Functions}

   FUNCTION gammln(xx: double): double;

   FUNCTION factrl(n: integer): double;
   (* Programs using routing FACTRL must declare the variables  
    VAR
     glntop: integer;
     gla: ARRAY [1..33] OF double;
    and initialize the values
     glntop := 0;
     gla[1] := 1.0;
    in the main routine. *)

   FUNCTION factln(n: integer): double;
   (* Programs using routine FACTLN must declare the array
    VAR
     glna: ARRAY [1..100] OF double;
    and must initialize the array to the values
     FOR i := 1 TO 100 DO glna[i] := -1.0;
    in the main routine. *)

   FUNCTION bico(n,k: integer): double;
    {Binomial Coefficient}

   FUNCTION erfcc(x: double): double;
   {Complimentary error function}

   FUNCTION bessi0(x: double): double;

   FUNCTION bessi1(x: double): double;

   FUNCTION bessi(n: integer; x: double): double;

   FUNCTION bessj0(x: double): double;

   FUNCTION bessj1(x: double): double;

   FUNCTION sign(x: double): double;

   FUNCTION bessj(n: integer; x: double): double;

   FUNCTION bessk0(x: double): double;

   FUNCTION bessk1(x: double): double;

   FUNCTION bessk(n: integer; x: double): double;

   FUNCTION bessy0(x: double): double;

   FUNCTION bessy1(x: double): double;

   FUNCTION bessy(n: integer; x: double): double;

   FUNCTION Si(x: double):double;

   FUNCTION Ci(x: double):double;

   procedure Fresnel(x:double;var f,g:double);
   {Calculates auxilliary functions for Fresnel integrals. See Boersma.
     Mathematical Computation Vol 14 p 380 }

   function FrC(x:double):double;
   {Fresnel Cosine integral. See Boersma. Mathematical Computation Vol 14 p 380}

   function  FrS(x:double):double;
   {Fresnel Sine integral. See Boersma. Mathematical Computation Vol 14
    p 380}

   function  Expression(SExp:String;Var Ecode,Ecode1,Ecode2:Integer):double;
   {Attempts to evalate the value of a string repesentation of an expression }

   Within expression the following procedures are defined:

      Procedure CheckTopOp;
      {Checks operation stack }

      Procedure CheckTopNum;
      {Checks number stack }

      Procedure RemoveSpace(i:integer);
      {Removes a space or unwanted character from ss}

      Procedure Stophere(c:string);
      { Diagnostic Tool  - Not normally used
        Must be altered for Win95 systems. }

      Procedure PerformOp;
      { Performs a mathematical operation }

      Function FunctionCode(Fnumber:integer;var ErrCode:integer):string;
      {Generates a string to represent a Function and sets FnClass and
       NumOfArgs to check for correct number of arguments }

             End of Expression

   Procedure ResetPars(Rst:integer);
   {Resets parameters
      Rst = 2 Resets Angle and Output number Format
      Rst = 1 Resets Other parameters
      Rst = 3 Resets everything.}

   procedure RemoveQuotes(Var ss:string);
   {Removes Quotes from a simpleString}

   Procedure Analyse(s1:string;var StringNum:integer);
   {Analyses a string into its constituent components and attempts to
    express each component as a command, variable, function, etc.}

   Function GetLine(Var LineNum:Integer):String;
   { This starts at line number LineNum and attempts to construct
     a compound line by adding continuation lines and skipping
     comment lines. If successful the result is returned as the
     function. Non catastrophic failures allow optional continuation.
     Catastrophic failures also set the Global Flag 'Disaster'.
     Various error messages may be returned.}

   Function GetResult(Var ResetIt,Enum:Integer;s1:String;
              var out1a,out1b,out1c,out1d,out1e:String):Double;
   { This is the main function which takes an input string s1 from the
     calling program and attempts to evaluate it to a mathematical or
     graphical operation. 
     not used by GLE }



